<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/9/15
 * Time: 15:21
 */

namespace app\user\admin;
use app\admin\controller\Admin;
use app\common\builder\ZBuilder;
use think\Db;

/**
 * 记录
 * @package app\user\admin
 */
class Content extends Admin
{
    /**
     * 账变记录首页 吴杰
* @return mixed
    * @throws \think\Exception
    * @throws \think\exception\DbException
    */
    public function index()
{
	
    $data_list = Db::name('user_account')
	   ->where('pid',is_signin())
	    ->where($this->getMap())
        ->order($this->getOrder('id DESC'))
        ->paginate();

    $con=[
        1=>'投注',
        2=>'返奖',
        3=>'充值',
        4=>'提现',
		5=>'冻结',
		6=>'解冻',
    ];

    return ZBuilder::make('table')
        ->setTableName('account')
        ->addTopButton('delete')
        ->addRightButton('delete')
        ->addColumns([
            ['__INDEX__', 'ID'],
            ['order_id', '订单编号'],
            ['username', '用户名'],
            ['name', '昵称'],
            ['type', '账变类型',$con],
            ['caizhong', '彩种类型'],
            ['money', '账变前金额（元）'],
            ['lastmoney', '账变后金额（元）'],
            ['time', '账变时间', 'datetime'],
            ['caicontent', '账变备注'],
            ['right_button', '操作', 'btn'],
        ])
        ->setColumnWidth('time', 130)
		->setColumnWidth('order_id', 130)
        ->setColumnWidth('id', 60)
        ->setColumnWidth('caicontent', 300)
        ->addFilter('username')
        ->addFilter('name')
        ->addFilter('order_id')
        ->addFilter('type',$con)
        ->setRowList($data_list)
        ->fetch();
}

    /**
     * 登录日志记录首页 吴杰
     * @return mixed
     * @throws \think\Exception
     * @throws \think\exception\DbException
     */
    public function login()
    {
        $data_list = Db::name('user_login')->where('aid',is_signin())
					   ->where($this->getMap())
					   ->order($this->getOrder('id DESC'))
					   ->paginate();

        return ZBuilder::make('table')
            ->setTableName('login')
            ->addTopButton('delete')
            ->addRightButton('delete')
            ->addColumns([
                ['__INDEX__', 'ID'],
                ['username', '用户名'],
                ['ip', 'ip地址'],
                ['time', '操作时间'],
                ['right_button', '操作', 'btn'],
            ])
            ->addFilter('username')
            ->addFilter('ip')
            ->setRowList($data_list)
            ->fetch();
    }
}